#pragma once

#include "icmp_context.hpp"
#include "icmp_packet.hpp"
#include "limbo/ip/state.hpp"
#include "opts.h"

namespace limbo::icmp {

template <typename NextState, int options = 0> struct State {
  using Context = IcmpContext<State>;
  using Packet = IcmpPacket<State>;
  using LowerState = NextState;
  using LowerPacket = typename LowerState::Packet;
  static constexpr int opts = options;

  Result recv(Chunk buff, LowerState *lower_state) {
    return packet.recv(buff, *this, lower_state);
  }

  Packet &get_parsed() { return packet; }

  inline bool select(const LowerPacket *packet) {
    return packet->proto == static_cast<uint8_t>(ip::Proto::icmp);
  }

  Packet packet;
};

} // namespace limbo::icmp
